package schoolWork.work04.test3;

public class Test2 {
    public static void main(String[] args) {
        int[] arr = {1,2,3};
        try{
            //调用方法
            printarr(arr);
        }catch (Exception e){
            System.out.println(e.getMessage());
        }

    }

    public static void printarr(int[] arr) throws Exception{
        // 打印数组
        for (int i = 0; i < 4; i++) {
            if(i == 3)
                throw new Exception("数组下界越界异常");
            else
                System.out.print(arr[i] + " ");
        }
    }
}
